package com.xgkj.diyiketang.task;

import com.alibaba.fastjson.JSONObject;
import com.xgkj.diyiketang.http.CouponHttpRequest;
import com.xgkj.diyiketang.http.CouponHttpResponse;
import com.xgkj.diyiketang.http.engine.CouponHttpBaseTask;
import com.xgkj.diyiketang.http.engine.TaskResultCode;

/**
 * Created by Administrater on 2015/12/7.
 */
public class ShouCangTask extends CouponHttpBaseTask {

    private String mVideoId;
    private String mType,mFlag;

    public ShouCangTask(String videoId, String type, String flag){
        super(TaskType.SHOUCANG_TASK);
        mVideoId =videoId;
        mType = type;
        mFlag = flag;
    }

    @Override
    protected void processResponseData(CouponHttpResponse response) {
        notifyTaskCompleted(TaskResultCode.SUCCESS, null);
    }

    @Override
    protected void prepareRequest() {
        super.prepareRequest();
        if (mPhase == TASK_PHASE_INIT) {
            CouponHttpRequest request = new CouponHttpRequest(RequestType.SHOUCANG_REQUEST);
            JSONObject json = new JSONObject();
            json.put("videoId", mVideoId);
            json.put("type", mType);
            if (mFlag != null){
                json.put("flag", mFlag);
            }

            request.setData(json.toString());
            request.setApiNo(ApiNo.SHOUCANG);
            addRequest(request);
        }
    }

}
